﻿using System.ComponentModel.DataAnnotations;

// ReSharper disable once CheckNamespace
namespace IFoxCAD.WPF;

/// <summary>
/// 大于
/// </summary>
/// <param name="value">值</param>
/// <param name="canEqual">可以等于</param>
public class BiggerThanDoubleAttribute(double value, bool canEqual = false) : ValidationAttribute
{
    public override bool IsValid(object? value1)
    {
        if (value1 is not double d)
            return false;
        return canEqual ? d >= value : d > value;
    }
}

/// <summary>
/// 小于
/// </summary>
/// <param name="value">值</param>
/// <param name="canEqual">可以等于</param>
public class SmallerThanDoubleAttribute(double value, bool canEqual = false) : ValidationAttribute
{
    public override bool IsValid(object? value1)
    {
        if (value1 is not double d)
            return false;
        return canEqual ? d <= value : d < value;
    }
}